package com.ctbri.arrays;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

class MyList<T> extends ArrayList<T> {
	public MyList(List<T> list) {
		super(list);
	}
	public List<T> getReversed() {
		List<T> list = this.subList(0, this.size());
		Collections.sort(list, Collections.reverseOrder());
		return list;
	}
}
public class Ex25 {

	public static void main(String[] args) {
		List<Integer> aList = new ArrayList<>(Arrays.asList(1, 2, 3, 4, 5));
		System.out.println(aList.getClass());
		System.out.println(aList);
		System.out.println(aList.get(4));
		aList.add(6);
		aList.addAll(Arrays.asList(7, 8));
		System.out.println(aList);
		List<Integer> aSlice = aList.subList(2, 4);
		System.out.println(aSlice);
		
		MyList<Integer> list = new MyList<Integer>(aList);
		System.out.println(list.getClass());
		System.out.println(list.getReversed());
	}

}
